<template>
  <el-container class="main_container">
    <!--头部样式-->
    <el-header>
      <!--左边的logo和系统名称-->
      <div class="left_box">
        <img src="../assets/img/quantou.jpg">
        <span>新冠物资管理系统</span>
      </div>
      <!--右边登录展示的头像-->
      <div class="right_box">
        <el-dropdown>
          <img src="../assets/img/avatar.gif"/>
          <!--下拉菜单-->
          <el-dropdown-menu slot="dropdown">
            <el-dropdown-item icon="el-icon-house">系统首页</el-dropdown-item>
            <el-dropdown-item icon="el-icon-ship">交流讨论</el-dropdown-item>
            <el-dropdown-item icon="el-icon-switch-button">退出登录</el-dropdown-item>
          </el-dropdown-menu>
        </el-dropdown>
      </div>
    </el-header>
    <el-container>
      <!--侧边栏-->
      <el-aside :width="isCollapse?'60px':'200px'">
        <div class="toggle_box" @click="toggleMenu">
          |||
        </div>
        <el-menu
          default-active="2"
          :collapse="isCollapse"
          :collapse-transition="false"
          class="el-menu-vertical-demo"
          background-color="#001529"
          text-color="#fff"
          active-text-color="#ffd04b"
          :default-active="activePath"
          :unique-opened="true"
          :router="true">
          <MenuTree :menuList="menuList"></MenuTree>
        </el-menu>
      </el-aside>
      <el-main>
        <!--路由视图-->
        <router-view></router-view>
      </el-main>
    </el-container>
  </el-container>
</template>

<script>
// 引入MenuTree
import MenuTree from '../components/MenuTree'

export default {
  name: "main1",

  data() {
    return {
      "isCollapse": false,
      activePath: "",
      "menuList": [
        {
          "id": 1,
          "parentId": 0,
          "menuName": "系统管理",
          "url": "",
          "icon": "el-icon-setting",
          "orderNum": 1,
          "open": 1,
          "disabled": false,
          "perms": null,
          "type": 0,
          "children": [
            {
              "id": 253,
              "parentId": 1,
              "menuName": "欢迎页面",
              "url": "/welcome",
              "icon": "el-icon-star-off",
              "orderNum": 1,
              "open": 0,
              "disabled": false,
              "perms": "welcome:view",
              "type": 0,
              "children": []
            },
            {
              "id": 226,
              "parentId": 1,
              "menuName": "用户管理",
              "url": "/users",
              "icon": "el-icon-user",
              "orderNum": 2,
              "open": 0,
              "disabled": false,
              "perms": "users",
              "type": 0,
              "children": []
            },
            {
              "id": 321,
              "parentId": 1,
              "menuName": "附件管理",
              "url": "/attachments",
              "icon": "el-icon-picture-outline",
              "orderNum": 2,
              "open": 1,
              "disabled": false,
              "perms": "",
              "type": 0,
              "children": []
            },
            {
              "id": 4,
              "parentId": 1,
              "menuName": "菜单权限",
              "url": "/menus",
              "icon": "el-icon-help",
              "orderNum": 3,
              "open": 0,
              "disabled": false,
              "perms": null,
              "type": 0,
              "children": []
            },
            {
              "id": 235,
              "parentId": 1,
              "menuName": "角色管理",
              "url": "/roles",
              "icon": "el-icon-postcard",
              "orderNum": 3,
              "open": 0,
              "disabled": false,
              "perms": "",
              "type": 0,
              "children": []
            },
            {
              "id": 261,
              "parentId": 1,
              "menuName": "部门管理",
              "url": "/departments",
              "icon": "el-icon-s-home",
              "orderNum": 3,
              "open": 0,
              "disabled": false,
              "perms": "",
              "type": 0,
              "children": []
            },
            {
              "id": 319,
              "parentId": 1,
              "menuName": "公告管理",
              "url": "/notices",
              "icon": "el-icon-s-flag",
              "orderNum": 4,
              "open": 0,
              "disabled": true,
              "perms": "",
              "type": 0,
              "children": []
            }
          ]
        },
        {
          "id": 2,
          "parentId": 0,
          "menuName": "物资管理",
          "url": "",
          "icon": "el-icon-setting",
          "orderNum": 1,
          "open": 1,
          "disabled": false,
          "perms": null,
          "type": 0,
          "children": [
            {
              "id": 253,
              "parentId": 1,
              "menuName": "欢迎页面",
              "url": "/welcome",
              "icon": "el-icon-star-off",
              "orderNum": 1,
              "open": 0,
              "disabled": false,
              "perms": "welcome:view",
              "type": 0,
              "children": []
            },
            {
              "id": 226,
              "parentId": 1,
              "menuName": "用户管理",
              "url": "/users",
              "icon": "el-icon-user",
              "orderNum": 2,
              "open": 0,
              "disabled": false,
              "perms": "users",
              "type": 0,
              "children": []
            },
            {
              "id": 321,
              "parentId": 1,
              "menuName": "附件管理",
              "url": "/attachments",
              "icon": "el-icon-picture-outline",
              "orderNum": 2,
              "open": 1,
              "disabled": false,
              "perms": "",
              "type": 0,
              "children": []
            },
            {
              "id": 4,
              "parentId": 1,
              "menuName": "菜单权限",
              "url": "/menus",
              "icon": "el-icon-help",
              "orderNum": 3,
              "open": 0,
              "disabled": false,
              "perms": null,
              "type": 0,
              "children": []
            },
            {
              "id": 235,
              "parentId": 1,
              "menuName": "角色管理",
              "url": "/roles",
              "icon": "el-icon-postcard",
              "orderNum": 3,
              "open": 0,
              "disabled": false,
              "perms": "",
              "type": 0,
              "children": []
            },
            {
              "id": 261,
              "parentId": 1,
              "menuName": "部门管理",
              "url": "/departments",
              "icon": "el-icon-s-home",
              "orderNum": 3,
              "open": 0,
              "disabled": false,
              "perms": "",
              "type": 0,
              "children": []
            },
            {
              "id": 319,
              "parentId": 1,
              "menuName": "公告管理",
              "url": "/notices",
              "icon": "el-icon-s-flag",
              "orderNum": 4,
              "open": 0,
              "disabled": true,
              "perms": "",
              "type": 0,
              "children": []
            }
          ]
        }
      ]
    }
  },
  components:
    {
      MenuTree
    },
  methods: {
    toggleMenu() {
      // 取反
      this.isCollapse = !this.isCollapse;
    }
  }
}
</script>

<style lang="less" scoped>
.main_container {
  height: 100%;
}

/*头部布局*/
.el-header {
  background-color: #001529;
  color: #FFFFFF;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 20px;
  padding: 0px;

  .left_box {
    display: flex;
    align-items: center;

    img {
      width: 60px;
      height: 60px;
      margin: 15px 0px 10px 15px;
    }

    /*标题*/

    span {
      margin-left: 15px;
    }
  }

  .right_box {
    .el-dropdown > img {
      width: 60px;
      height: 60px;
      border-radius: 50%;
      background-color: #FFFFFF;
      margin: 0px 15px 0px 0px;
      background-size: contain;
    }

  }
}

.el-aside {

  background-color: #001529;

  .el-menu {
    border-right: none;
  }

  .toggle_box {
    background-color: #16ff5e;
    font-size: 15px;
    font-weight: bold;
    cursor: pointer;
    letter-spacing: 0.2em;
    color: #FFFFFF;
    text-align: center;
  }
}

.el-main {
  background-color: #E9EEF3;
}

body > .el-container {
  margin-bottom: 40px;
}

/*下拉菜单样式*/
.el-dropdown-link {
  cursor: pointer;
  color: #409EFF;
}


</style>
